/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package fr.cggveritas.crewintranet.jms.entities;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
import org.codehaus.jackson.annotate.JsonIgnore;

/**
 *
 * @author Alassane
 */
@Entity
@Table(name = "cv_posteoccupe")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "CvPosteoccupe.findAll", query = "SELECT c FROM CvPosteoccupe c"),
    @NamedQuery(name = "CvPosteoccupe.findByIdposteoccupe", query = "SELECT c FROM CvPosteoccupe c WHERE c.idposteoccupe = :idposteoccupe")})
public class CvPosteoccupe implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "idposteoccupe")
    private Integer idposteoccupe;
    @JoinColumn(name = "cv_listeposte_idposte", referencedColumnName = "idposte")
    @ManyToOne(optional = false, fetch = FetchType.EAGER)
    private CvListeposte cvListeposteIdposte;
    @OneToMany(mappedBy = "cvPosteoccupeIdposteoccupe", fetch = FetchType.LAZY)
    private List<CvTravailleur> cvTravailleurList;

    public CvPosteoccupe() {
    }

    public CvPosteoccupe(Integer idposteoccupe) {
        this.idposteoccupe = idposteoccupe;
    }

    public Integer getIdposteoccupe() {
        return idposteoccupe;
    }

    public void setIdposteoccupe(Integer idposteoccupe) {
        this.idposteoccupe = idposteoccupe;
    }

    public CvListeposte getCvListeposteIdposte() {
        return cvListeposteIdposte;
    }

    public void setCvListeposteIdposte(CvListeposte cvListeposteIdposte) {
        this.cvListeposteIdposte = cvListeposteIdposte;
    }

    @XmlTransient
    @JsonIgnore
    public List<CvTravailleur> getCvTravailleurList() {
        return cvTravailleurList;
    }

    public void setCvTravailleurList(List<CvTravailleur> cvTravailleurList) {
        this.cvTravailleurList = cvTravailleurList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idposteoccupe != null ? idposteoccupe.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof CvPosteoccupe)) {
            return false;
        }
        CvPosteoccupe other = (CvPosteoccupe) object;
        if ((this.idposteoccupe == null && other.idposteoccupe != null) || (this.idposteoccupe != null && !this.idposteoccupe.equals(other.idposteoccupe))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "fr.cggveritas.crewintranet.jms.entities.CvPosteoccupe[ idposteoccupe=" + idposteoccupe + " ]";
    }
    
}
